package com.example.api.repository;

import com.example.api.entity.Users;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepository extends JpaRepository<Users, Integer> {
    Users findByUsername(String username);
    Users findByEmail(String email);


    // 模糊搜索用户
    @Query("SELECT u FROM Users u WHERE u.username LIKE %:keyword% OR u.email LIKE %:keyword%")
    List<Users> searchByUsernameOrEmail(@Param("keyword") String keyword);

}
